<template>
  <view class="normal-login-container">

    <view class="item-wrap" style="margin-bottom: 0">
      <view class="lineBottom10">
        <uni-section title="基础信息" type="line"/>
      </view>

      <view style="margin: 8rpx 0 8rpx 20rpx">
        <uni-forms labelWidth="auto">
          <uni-forms-item label="车辆总台数:" v-if="carNum > 1">
            <text>{{ carNum || '-' }}</text>
          </uni-forms-item>

          <uni-forms-item label="合计费用:">
            <text>{{ totalPrice  || 0}}</text>
          </uni-forms-item>

          <uni-forms-item label="客户名称:">
            <text>{{ ruleForm.customerName || '-' }}</text>
          </uni-forms-item>

          <uni-forms-item label="合同禀议号:">
            <text>{{ ruleForm.contractReportNumber || '-' }}</text>
          </uni-forms-item>

          <uni-forms-item label="采购禀议号:">
            <text>{{ ruleForm.procurementReportNumber || '-' }}</text>
          </uni-forms-item>

          <uni-forms-item label="车辆产权:">
            <text>{{ ruleForm.propertyRightName || '-' }}</text>
          </uni-forms-item>

          <uni-forms-item label="车辆归属:">
            <text>{{ ruleForm.ascription || '-' }}</text>
          </uni-forms-item>

          <uni-forms-item label="车辆运营城市:">
            <text>{{ ruleForm.operationsName || '-' }}</text>
          </uni-forms-item>
          <uni-forms-item label="车辆大区:">
            <text>{{ ruleForm.region || '-' }}</text>
          </uni-forms-item>

          <uni-forms-item label="品牌/车系/车型:">
            <text v-if="ruleForm.brandName">{{ ruleForm.brandName }}/</text>
            <text v-if="ruleForm.seriesName">{{ ruleForm.seriesName }}/</text>
            <text>{{ ruleForm.modelName || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="车架号:" v-if="carNum === 1">
            <text>{{ ruleForm.vinNo || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="车牌号:" v-if="carNum === 1">
            <text>{{ ruleForm.carNo || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="车辆状态:" v-if="carNum === 1">
            <text>{{ handleLabel(dict.type.car_business_type, ruleForm.businessType) }}</text>
          </uni-forms-item>

          <uni-forms-item label="处理人:">
            <text>{{ ruleForm.processedByName || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="处理时间:">
            <text>{{ ruleForm.processedByTime || '-'}}</text>
          </uni-forms-item>

          <uni-forms-item label="工单创建时间:">
            <text>{{ A_formatTime(ruleForm.createTime) || '-' }}</text>
          </uni-forms-item>

        </uni-forms>
      </view>
    </view>
  </view>
</template>

<script>
import {miniProgramInfo} from "@/api/purchaseTax";
import {A_formatTime} from "@/utils/utils.js"
export default {
  name: 'basicInfo',//基础信息
  dicts: ['customer_type', 'car_business_type'],
  props: {
    workId: {
      type: Array,
      default: []
    },
    carNum: {
      type: Number,
      default: 0
    },
    totalPrice: {
      type: Number,
      default: 0
    }
  },
  computed: {
    handleLabel() {
      return function (arr, type) {
        let name = '-'
        arr.map((v) => {
          if (type == v.value) {
            name = v.label;
          }
        });
        return name
      }
    }
  },
  watch: {
    workId: {
      handler(val) {
        if (val && val.length > 0) {
          this.handleList(val)
        }
      },
      deep: true
    }
  },
  data() {
    return {
      ruleForm: {}
    };
  },
  created() {
  },
  mounted() {

  },
  methods: {
    async handleList(id) {
      try {
        let res = await miniProgramInfo(id)
        this.ruleForm = res.data
      } catch (e) {
        console.error(e)
      }
    },


  },
};
</script>

<style lang="scss" scoped>
.car-wrap {
  display: flex;
  flex-direction: column;
  padding: 20rpx 20rpx 20rpx 0;
  border: 1px solid #dadada;
  margin: 10rpx 20rpx;
  border-radius: 8rpx;

}


</style>


